<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>WLog: ILogProcess.cpp源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- 制作者 Doxygen 1.5.8 -->
<script type="text/javascript">
<!--
function changeDisplayState (e){
  var num=this.id.replace(/[^[0-9]/g,'');
  var button=this.firstChild;
  var sectionDiv=document.getElementById('dynsection'+num);
  if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
    sectionDiv.style.display='block';
    button.src='open.gif';
  }else{
    sectionDiv.style.display='none';
    button.src='closed.gif';
  }
}
function initDynSections(){
  var divs=document.getElementsByTagName('div');
  var sectionCounter=1;
  for(var i=0;i<divs.length-1;i++){
    if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
      var header=divs[i];
      var section=divs[i+1];
      var button=header.firstChild;
      if (button!='IMG'){
        divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
        button=document.createElement('img');
        divs[i].insertBefore(button,divs[i].firstChild);
      }
      header.style.cursor='pointer';
      header.onclick=changeDisplayState;
      header.id='dynheader'+sectionCounter;
      button.src='closed.gif';
      section.id='dynsection'+sectionCounter;
      section.style.display='none';
      section.style.marginLeft='14px';
      sectionCounter++;
    }
  }
}
window.onload = initDynSections;
-->
</script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>首页</span></a></li>
      <li><a href="namespaces.html"><span>名字空间</span></a></li>
      <li><a href="annotated.html"><span>类</span></a></li>
      <li class="current"><a href="files.html"><span>文件</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>文件列表</span></a></li>
      <li><a href="globals.html"><span>文件成员</span></a></li>
    </ul>
  </div>
<h1>ILogProcess.cpp</h1><a href="ILogProcess_8cpp.html">浏览该文件的文档。</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include &lt;assert.h&gt;</span>
<a name="l00003"></a>00003 
<a name="l00004"></a>00004 <span class="preprocessor">#include "<a class="code" href="ILogProcess_8h.html">ILogProcess.h</a>"</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include "<a class="code" href="Record_8h.html">Record.h</a>"</span>
<a name="l00006"></a>00006 <span class="preprocessor">#include "<a class="code" href="IOuter_8h.html">IOuter.h</a>"</span>
<a name="l00007"></a>00007 
<a name="l00008"></a>00008 <span class="keyword">namespace </span>WLog
<a name="l00009"></a>00009 {
<a name="l00010"></a><a class="code" href="classWLog_1_1ILogProcess.html#0dca4c62ee5c6ccda16212992b26296f">00010</a>     <a class="code" href="classWLog_1_1ILogProcess.html#0dca4c62ee5c6ccda16212992b26296f" title="以一个输出对象IOuter来初始化类.">ILogProcess::ILogProcess</a>(<a class="code" href="classWLog_1_1IOuter.html" title="Interface for output Record with define Log Level.">IOuter</a> *pOuter <span class="comment">/*= NULL*/</span>, <span class="keywordtype">int</span> iOutLevel <span class="comment">/*= W_LEVEL_FLOOR*/</span>)
<a name="l00011"></a>00011         : m_pOuter(pOuter), m_iOutLevel(iOutLevel)
<a name="l00012"></a>00012     {
<a name="l00013"></a>00013         init();
<a name="l00014"></a>00014     }
<a name="l00015"></a>00015         
<a name="l00016"></a><a class="code" href="classWLog_1_1ILogProcess.html#a7593f0f3235ea4e5e9ce22fbef650a7">00016</a>     <a class="code" href="classWLog_1_1ILogProcess.html#a7593f0f3235ea4e5e9ce22fbef650a7">ILogProcess::~ILogProcess</a>()
<a name="l00017"></a>00017     {
<a name="l00018"></a>00018 <span class="preprocessor">#if WLOG_ADD_LEVEL_DEFAULT</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span>        <span class="keyword">delete</span> this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[<a class="code" href="WLDefine_8h.html#d4c34eb904d0cbf7e563d2248318c716">W_LEVEL_TRACE</a>];
<a name="l00020"></a>00020         <span class="keyword">delete</span> this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[<a class="code" href="WLDefine_8h.html#9a6ecd992c3301acb95305dc2685bbb6">W_LEVEL_INFO</a>];
<a name="l00021"></a>00021         <span class="keyword">delete</span> this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[<a class="code" href="WLDefine_8h.html#7f1da0a3570643530d2cb569a47e11a2">W_LEVEL_DEBUG</a>];
<a name="l00022"></a>00022         <span class="keyword">delete</span> this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[<a class="code" href="WLDefine_8h.html#de67eb3563a4fe59a2b4a1ebb3ff3eee">W_LEVEL_WARNING</a>];
<a name="l00023"></a>00023         <span class="keyword">delete</span> this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[<a class="code" href="WLDefine_8h.html#a4a741e5407069c19089c58e097c9af5">W_LEVEL_NOTICE</a>];
<a name="l00024"></a>00024         <span class="keyword">delete</span> this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[<a class="code" href="WLDefine_8h.html#8b90883dd25a57a688c6524d5dac9222">W_LEVEL_ERROR</a>];
<a name="l00025"></a>00025         <span class="keyword">delete</span> this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[<a class="code" href="WLDefine_8h.html#a317cbbde9dd3e0df0b8dedac084b590">W_LEVEL_ASSERT</a>];
<a name="l00026"></a>00026         <span class="keyword">delete</span> this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[<a class="code" href="WLDefine_8h.html#0dc746d4ddb9530c15d95d57b2f4e6f8">W_LEVEL_FATAL</a>];
<a name="l00027"></a>00027         <span class="keyword">delete</span> this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[<a class="code" href="WLDefine_8h.html#2ac00b1762067e2fe194748f286a946a">W_LEVEL_OUTPUT</a>];
<a name="l00028"></a>00028 <span class="preprocessor">#endif      </span>
<a name="l00029"></a>00029 <span class="preprocessor"></span>    }
<a name="l00030"></a>00030 
<a name="l00031"></a><a class="code" href="classWLog_1_1ILogProcess.html#acc84762d50a7a0ec71453b1534094a4">00031</a>     <span class="keywordtype">bool</span> <a class="code" href="classWLog_1_1ILogProcess.html#acc84762d50a7a0ec71453b1534094a4" title="向类里面添加不同级别的 ILevel.">ILogProcess::addLevel</a>(<a class="code" href="classWLog_1_1ILevel.html" title="Define Interface for Log Level.">ILevel</a> *pLevel)
<a name="l00032"></a>00032     {
<a name="l00033"></a>00033         <span class="keywordflow">if</span> (this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[pLevel-&gt;<a class="code" href="classWLog_1_1ILevel.html#652b09fa23f53092827c789330c53095" title="得到当前Log定义的级别.">getLevel</a>()])
<a name="l00034"></a>00034         {<span class="comment">//已经存在</span>
<a name="l00035"></a>00035             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00036"></a>00036         }
<a name="l00037"></a>00037         this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[pLevel-&gt;<a class="code" href="classWLog_1_1ILevel.html#652b09fa23f53092827c789330c53095" title="得到当前Log定义的级别.">getLevel</a>()] = pLevel;
<a name="l00038"></a>00038 
<a name="l00039"></a>00039         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00040"></a>00040     }
<a name="l00041"></a>00041 
<a name="l00042"></a><a class="code" href="classWLog_1_1ILogProcess.html#035c1a508ac1492b9344a510e317f668">00042</a>     <span class="keywordtype">void</span> <a class="code" href="classWLog_1_1ILogProcess.html#035c1a508ac1492b9344a510e317f668" title="设置输出级别.">ILogProcess::setOutLevel</a>(<span class="keywordtype">int</span> iOutLevel)
<a name="l00043"></a>00043     {
<a name="l00044"></a>00044         this-&gt;m_iOutLevel = iOutLevel;
<a name="l00045"></a>00045     }
<a name="l00046"></a>00046 
<a name="l00047"></a><a class="code" href="classWLog_1_1ILogProcess.html#fbb6db887defa09683f91b7059f6f703">00047</a>     <span class="keywordtype">int</span> <a class="code" href="classWLog_1_1ILogProcess.html#fbb6db887defa09683f91b7059f6f703" title="获取类的输出级别.">ILogProcess::getOutLevel</a>()
<a name="l00048"></a>00048     {
<a name="l00049"></a>00049         <span class="keywordflow">return</span> this-&gt;m_iOutLevel;
<a name="l00050"></a>00050     }
<a name="l00051"></a>00051 
<a name="l00052"></a><a class="code" href="classWLog_1_1ILogProcess.html#ce3c7d8721cd6e40d2e4ae22504f5df5">00052</a>     <a class="code" href="classWLog_1_1IOuter.html" title="Interface for output Record with define Log Level.">IOuter</a>* <a class="code" href="classWLog_1_1ILogProcess.html#ce3c7d8721cd6e40d2e4ae22504f5df5" title="设置类的输出对象IOuter.">ILogProcess::setOuter</a>(<a class="code" href="classWLog_1_1IOuter.html" title="Interface for output Record with define Log Level.">IOuter</a> *pOuter)
<a name="l00053"></a>00053     {
<a name="l00054"></a>00054         <a class="code" href="classWLog_1_1IOuter.html" title="Interface for output Record with define Log Level.">IOuter</a>* pSaveOuter = this-&gt;m_pOuter;
<a name="l00055"></a>00055         
<a name="l00056"></a>00056         this-&gt;m_pOuter = pOuter;
<a name="l00057"></a>00057         
<a name="l00058"></a>00058         <span class="keywordflow">return</span> pSaveOuter;
<a name="l00059"></a>00059     }
<a name="l00060"></a>00060         
<a name="l00061"></a><a class="code" href="classWLog_1_1ILogProcess.html#51eb815cb699c63c370bee4788a285b0">00061</a>     <a class="code" href="classWLog_1_1IOuter.html" title="Interface for output Record with define Log Level.">IOuter</a>* <a class="code" href="classWLog_1_1ILogProcess.html#51eb815cb699c63c370bee4788a285b0" title="获取类的输出对象IOuter.">ILogProcess::getOuter</a>()
<a name="l00062"></a>00062     {
<a name="l00063"></a>00063         <span class="keywordflow">return</span> this-&gt;m_pOuter;
<a name="l00064"></a>00064     }
<a name="l00065"></a>00065 
<a name="l00066"></a>00066 <span class="comment">//private:</span>
<a name="l00067"></a>00067 
<a name="l00068"></a>00068     <span class="keywordtype">void</span> ILogProcess::init()
<a name="l00069"></a>00069     {
<a name="l00070"></a>00070         memset(this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>, 0, <span class="keyword">sizeof</span>(<a class="code" href="classWLog_1_1ILevel.html" title="Define Interface for Log Level.">ILevel</a>*) * <a class="code" href="WLDefine_8h.html#f2124a4fad13a6641c8dec64fdee276a">W_LEVEL_CEIL</a>);
<a name="l00071"></a>00071 <span class="preprocessor">#if WLOG_ADD_LEVEL_DEFAULT</span>
<a name="l00072"></a>00072 <span class="preprocessor"></span>        this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[<a class="code" href="WLDefine_8h.html#d4c34eb904d0cbf7e563d2248318c716">W_LEVEL_TRACE</a>] = <span class="keyword">new</span> <a class="code" href="classWLog_1_1ILevel.html" title="Define Interface for Log Level.">ILevel</a>(<a class="code" href="WLDefine_8h.html#d4c34eb904d0cbf7e563d2248318c716">W_LEVEL_TRACE</a>, <span class="stringliteral">"trace"</span>, <span class="stringliteral">"跟踪执行流程"</span>);
<a name="l00073"></a>00073         this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[<a class="code" href="WLDefine_8h.html#9a6ecd992c3301acb95305dc2685bbb6">W_LEVEL_INFO</a>] = <span class="keyword">new</span> <a class="code" href="classWLog_1_1ILevel.html" title="Define Interface for Log Level.">ILevel</a>(<a class="code" href="WLDefine_8h.html#9a6ecd992c3301acb95305dc2685bbb6">W_LEVEL_INFO</a>, <span class="stringliteral">"info"</span>, <span class="stringliteral">"输出一些正常信息"</span>);
<a name="l00074"></a>00074         this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[<a class="code" href="WLDefine_8h.html#7f1da0a3570643530d2cb569a47e11a2">W_LEVEL_DEBUG</a>] = <span class="keyword">new</span> <a class="code" href="classWLog_1_1ILevel.html" title="Define Interface for Log Level.">ILevel</a>(<a class="code" href="WLDefine_8h.html#7f1da0a3570643530d2cb569a47e11a2">W_LEVEL_DEBUG</a>, <span class="stringliteral">"debug"</span>, <span class="stringliteral">"打印调试信息"</span>);
<a name="l00075"></a>00075         this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[<a class="code" href="WLDefine_8h.html#de67eb3563a4fe59a2b4a1ebb3ff3eee">W_LEVEL_WARNING</a>] = <span class="keyword">new</span> <a class="code" href="classWLog_1_1ILevel.html" title="Define Interface for Log Level.">ILevel</a>(<a class="code" href="WLDefine_8h.html#de67eb3563a4fe59a2b4a1ebb3ff3eee">W_LEVEL_WARNING</a>, <span class="stringliteral">"warning"</span>, <span class="stringliteral">"警告"</span>);
<a name="l00076"></a>00076         this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[<a class="code" href="WLDefine_8h.html#a4a741e5407069c19089c58e097c9af5">W_LEVEL_NOTICE</a>] = <span class="keyword">new</span> <a class="code" href="classWLog_1_1ILevel.html" title="Define Interface for Log Level.">ILevel</a>(<a class="code" href="WLDefine_8h.html#a4a741e5407069c19089c58e097c9af5">W_LEVEL_NOTICE</a>, <span class="stringliteral">"notice"</span>, <span class="stringliteral">"通告，需要特别注意"</span>);
<a name="l00077"></a>00077         this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[<a class="code" href="WLDefine_8h.html#8b90883dd25a57a688c6524d5dac9222">W_LEVEL_ERROR</a>] = <span class="keyword">new</span> <a class="code" href="classWLog_1_1ILevel.html" title="Define Interface for Log Level.">ILevel</a>(<a class="code" href="WLDefine_8h.html#8b90883dd25a57a688c6524d5dac9222">W_LEVEL_ERROR</a>, <span class="stringliteral">"error"</span>, <span class="stringliteral">"可恢复错误报告"</span>);
<a name="l00078"></a>00078         this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[<a class="code" href="WLDefine_8h.html#a317cbbde9dd3e0df0b8dedac084b590">W_LEVEL_ASSERT</a>] = <span class="keyword">new</span> <a class="code" href="classWLog_1_1ILevel.html" title="Define Interface for Log Level.">ILevel</a>(<a class="code" href="WLDefine_8h.html#a317cbbde9dd3e0df0b8dedac084b590">W_LEVEL_ASSERT</a>, <span class="stringliteral">"assert"</span>, <span class="stringliteral">"assert"</span>, <a class="code" href="ILevel_8h.html#5fd2c751ba03efcdc0f6eaadbe175c9a">SIGNED_OUT_ALL</a>, <a class="code" href="namespaceWLog.html#6315f1351a7f92cf5bb70536413cb0da">cb_trimFileName</a>, <a class="code" href="namespaceWLog.html#05e19038a875320b3c71790d92a282cf">cb_assert</a>);
<a name="l00079"></a>00079         this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[<a class="code" href="WLDefine_8h.html#0dc746d4ddb9530c15d95d57b2f4e6f8">W_LEVEL_FATAL</a>] = <span class="keyword">new</span> <a class="code" href="classWLog_1_1ILevel.html" title="Define Interface for Log Level.">ILevel</a>(<a class="code" href="WLDefine_8h.html#0dc746d4ddb9530c15d95d57b2f4e6f8">W_LEVEL_FATAL</a>, <span class="stringliteral">"fatal"</span>, <span class="stringliteral">"不可恢复错误报告"</span>, <a class="code" href="ILevel_8h.html#5fd2c751ba03efcdc0f6eaadbe175c9a">SIGNED_OUT_ALL</a>, <a class="code" href="namespaceWLog.html#6315f1351a7f92cf5bb70536413cb0da">cb_trimFileName</a>, <a class="code" href="namespaceWLog.html#9ceab8f8dc49e6ae5886332c430b3573">cb_exit</a>); 
<a name="l00080"></a>00080         this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[<a class="code" href="WLDefine_8h.html#2ac00b1762067e2fe194748f286a946a">W_LEVEL_OUTPUT</a>] = <span class="keyword">new</span> <a class="code" href="classWLog_1_1ILevel.html" title="Define Interface for Log Level.">ILevel</a>(<a class="code" href="WLDefine_8h.html#2ac00b1762067e2fe194748f286a946a">W_LEVEL_OUTPUT</a>, <span class="stringliteral">"output"</span>, <span class="stringliteral">"只是简单的output"</span>, <a class="code" href="ILevel_8h.html#5642599debe6e90af72366d09c118c01">SIGNED_OUT_NONE</a>);
<a name="l00081"></a>00081 <span class="preprocessor">#endif</span>
<a name="l00082"></a>00082 <span class="preprocessor"></span>    }
<a name="l00083"></a>00083 
<a name="l00084"></a><a class="code" href="classWLog_1_1ILogProcess.html#81da7a7de8f4eece0f19a1f3fe3becbf">00084</a>     <span class="keywordtype">bool</span> <a class="code" href="classWLog_1_1ILogProcess.html#81da7a7de8f4eece0f19a1f3fe3becbf" title="添加一条记录">ILogProcess::pushRecord</a>(<a class="code" href="classWLog_1_1Record.html" title="记录类，记录一条信息的所有字段。">Record</a> record)
<a name="l00085"></a>00085     {
<a name="l00086"></a>00086         assert(this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#51eb815cb699c63c370bee4788a285b0" title="获取类的输出对象IOuter.">getOuter</a>());
<a name="l00087"></a>00087         <span class="keywordflow">if</span> (<a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[record.<a class="code" href="classWLog_1_1Record.html#1d571076a4074b5654c17e008f203fc5">m_nLevel</a>])
<a name="l00088"></a>00088         {
<a name="l00089"></a>00089             this-&gt;<a class="code" href="classWLog_1_1ILogProcess.html#51eb815cb699c63c370bee4788a285b0" title="获取类的输出对象IOuter.">getOuter</a>()-&gt;<a class="code" href="classWLog_1_1IOuter.html#ddd90dcabff0d77208866b6dd15fec8c" title="输出Record记录与Record对应的Level.">outRecord</a>(&amp;record, <a class="code" href="classWLog_1_1ILogProcess.html#04d7cf576224bbe3179a12d001e35bbb">m_pLevels</a>[record.<a class="code" href="classWLog_1_1Record.html#1d571076a4074b5654c17e008f203fc5">m_nLevel</a>]);
<a name="l00090"></a>00090             <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00091"></a>00091         }
<a name="l00092"></a>00092         <span class="keywordflow">return</span> <span class="keyword">false</span>;       
<a name="l00093"></a>00093     }
<a name="l00094"></a>00094 }
</pre></div></div>
<hr>
<address style="align: right;">
  Generated on Mon Apr 6 21:08:12 2009 for WLog by 韦体东<img src="logo.png" align="middle"/></address>
</body>
</html>
